import {
  q as n,
  ap as oe,
  X as F,
  f as ue,
  H as ie,
  av as V,
  aw as re,
  k as a,
  l as s,
  m as l,
  ax as ce,
  as as r,
  az as de,
  at as W,
  ay as fe
} from "./index-30f27935.js";
import { c as pe, s as k } from "./order-e84dc57e.js";
function J(p) {
  return (
    typeof p == "function" ||
    (Object.prototype.toString.call(p) === "[object Object]" && !fe(p))
  );
}
function ye(p) {
  const y = n([]),
    E = n([]),
    L = n({}),
    f = n(!0),
    g = n(1),
    m = n(10),
    C = n(1),
    w = n(10),
    c = n([]),
    v = n({}),
    b = n(),
    I = n(""),
    D = n(),
    _ = n(""),
    N = oe("reload"),
    x = F({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    z = F({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [5, 10, 20],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    U = F({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    O = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      {
        label: "用户ID",
        prop: "user_id",
        minWidth: 80,
        formatter: ({ user_id: e }) => `1${e}`
      },
      { label: "姓名", prop: "user_name", minWidth: 120 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "身份",
        prop: "user_vip",
        minWidth: 200,
        formatter: ({ user_vip: e, user_place: t }) =>
          a("div", null, [
            " ",
            a("span", null, [
              e == 1
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("VIP会员")] }
                  )
                : a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("普通会员")] }
                  )
            ]),
            a("span", null, [
              t == 1
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("一星合伙人")] }
                  )
                : t == 2
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("二星合伙人")] }
                  )
                : t == 3
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("三星合伙人")] }
                  )
                : t == 4
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("四星合伙人")] }
                  )
                : t == 5
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("五星合伙人")] }
                  )
                : t == 6
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("一星联创")] }
                  )
                : t == 7
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("二星联创")] }
                  )
                : t == 8
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("三星联创")] }
                  )
                : t == 9
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("四星联创")] }
                  )
                : t == 10
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("一星董事")] }
                  )
                : t == 11
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("二星董事")] }
                  )
                : t == 12
                ? a(
                    s("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [l("三星董事")] }
                  )
                : a(
                    s("el-tag"),
                    { class: "mx-1", type: "info", effect: "light" },
                    { default: () => [l("暂无")] }
                  )
            ])
          ])
      },
      {
        label: "门店码",
        prop: "store_code",
        minWidth: 100,
        formatter: ({ store_code: e }) =>
          a(
            s("el-tag"),
            { class: "mx-1", type: "success", effect: "light" },
            J(e) ? e : { default: () => [e] }
          )
      },
      { label: "门店名称", prop: "store_name", minWidth: 150 },
      { label: "首单", prop: "store_shou", minWidth: 100 },
      { label: "复购", prop: "store_fu", minWidth: 100 },
      { label: "操作", fixed: "right", width: 200, slot: "operation" }
    ],
    M = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "用户ID", prop: "user_id", minWidth: 80 },
      { label: "姓名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 80 },
      { label: "门店码", prop: "store_code", minWidth: 100 },
      { label: "门店名称", prop: "store_name", minWidth: 100 },
      { label: "首单", prop: "store_shou", minWidth: 100 },
      { label: "复购", prop: "store_fu", minWidth: 100 }
    ],
    R = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 150 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "商品名称",
        prop: "wares_name",
        minWidth: 250,
        formatter: ({ wares_name: e, store_name: t, store_code: o }) =>
          a("div", null, [
            a("div", null, [e]),
            t
              ? a(
                  s("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  J(t) ? t : { default: () => [t] }
                )
              : "",
            o
              ? a(
                  s("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [l("门店码:"), o] }
                )
              : ""
          ])
      },
      { label: "产品金额", prop: "wares_price", minWidth: 100 },
      {
        label: "内含瓶数",
        prop: "other_price",
        minWidth: 100,
        formatter: ({ wares_bottle: e, wares_num: t }) => e * t + " 瓶"
      },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) =>
          ce(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      }
    ],
    j = ue(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function B(e, t) {
    (v.value = e), (b.value = t);
    const o = {
        page: C.value,
        pagesize: w.value,
        store_code: e.store_code,
        wares_type_in: t
      },
      h = JSON.stringify(o),
      u = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(h)) },
      i = await pe(u);
    i.code == 200 &&
      ((E.value = i.data.indent.data), (z.total = i.data.indent.total));
  }
  async function T(e) {
    de(e);
  }
  async function Y(e) {
    const t = { id: e.id },
      o = JSON.stringify(t),
      d = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(o)) },
      u = await questionDelete(d);
    u.code == 200
      ? (W("删除成功", { type: "success" }), N())
      : W(u.msg, { type: "error" });
  }
  function H() {}
  function q(e) {
    (m.value = e), S(void 0, e);
  }
  function P(e) {
    (g.value = e), S(e, void 0);
  }
  function $(e) {}
  function X(e) {
    (w.value = e), B(v.value, b.value);
  }
  function G(e) {
    (C.value = e), B(v.value, b.value);
  }
  function K(e) {}
  function Q(e) {
    (U.text = `正在加载第${e}页...`),
      (f.value = !0),
      V(600).then(() => {
        f.value = !1;
      });
  }
  async function Z(e, t, o = [], h, d, u) {
    (c.value = []),
      o.map(se => {
        const le = se,
          ne = new Date(le);
        c.value.push(
          ne.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      }),
      (f.value = !0),
      (D.value = e),
      (I.value = d),
      (_.value = u);
    const i = {
        page: g.value,
        pagesize: m.value,
        name_phone: t || void 0,
        start: c.value[0],
        end: c.value[1],
        sort: u || void 0,
        store_code: d || void 0
      },
      te = JSON.stringify(i),
      ae = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(te)) },
      { data: A } = await k(ae);
    (y.value = A.data),
      (x.total = A.total),
      setTimeout(() => {
        f.value = !1;
      }, 500);
  }
  async function S(e = g.value, t = m.value) {
    const o = {
        page: e,
        pagesize: t,
        status: "1",
        start: c.value[0],
        end: c.value[1],
        store_code: I.value,
        sort: _.value
      },
      h = JSON.stringify(o),
      u = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(h)) },
      i = await k(u);
    i.code === 200
      ? ((y.value = i.data.data),
        (x.total = i.data.total),
        setTimeout(() => {
          f.value = !1;
        }, 500))
      : W(i.msg, { type: "error" });
  }
  const ee = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    ie(() => {
      V().then(() => {
        const { setWatermark: e } = re(p.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        S();
    }),
    {
      loading: f,
      columns: O,
      dataList: y,
      userColumns: R,
      pagination: x,
      buttonClass: j,
      userDatilList: E,
      orderInfo: L,
      columnsTable: M,
      count: g,
      pageCount: m,
      formattedDate: c,
      typeCount: D,
      paginationStore: z,
      handleLookUserDatil: B,
      handleSizeChangeStore: X,
      handleCurrentChangeStore: G,
      handleSelectionChangeStore: K,
      onSearch: Z,
      resetForm: ee,
      handleaddUser: H,
      handleUpdate: T,
      handleDelete: Y,
      handleSizeChange: q,
      handleCurrentChange: P,
      handleSelectionChange: $,
      onCurrentChange: Q
    }
  );
}
export { ye as useRole };
